//
//  CCYAllViewController.m
//  模拟-百思不得姐
//
//  Created by 程春玉 on 16/8/1.
//  Copyright © 2016年 chunyu. All rights reserved.
//

#import "CCYAllViewController.h"
#import "CCYNewViewController.h"
#import "CCYFriendTrendsViewController.h"
#import "CCYMeViewController.h"
#import "CCYTabBar.h"
#import "CCYNavigationController.h"
#import "JXPRecommendTableViewController.h"
#import "UIViewController+MMDrawerController.h"
#import "JXPCatalogueTableViewController.h"

@interface CCYAllViewController ()

@end

@implementation CCYAllViewController

+ (void)initialize
{
    NSMutableDictionary *attre = [NSMutableDictionary dictionary];
    attre[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attre[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectAttre = [NSMutableDictionary dictionary];
    selectAttre[NSFontAttributeName] = attre[NSFontAttributeName];
    selectAttre[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attre forState:(UIControlStateNormal)];
    [item setTitleTextAttributes:selectAttre forState:(UIControlStateSelected)];
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    抽屉的center页的vc
    JXPRecommendTableViewController *RecomVC = [[JXPRecommendTableViewController alloc] init];
    CCYNavigationController *recomNC = [[CCYNavigationController alloc] initWithRootViewController:RecomVC];
//    抽屉的left页面的vc
    JXPCatalogueTableViewController *menuVC = [[JXPCatalogueTableViewController alloc] init];
    CCYNavigationController *menuNC = [[CCYNavigationController alloc] initWithRootViewController:menuVC];
    MMDrawerController *mmDrawerVC = [[MMDrawerController alloc] initWithCenterViewController:recomNC leftDrawerViewController:menuNC rightDrawerViewController:nil];
//      添加打开的手势
    [mmDrawerVC setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
//      添加关闭的手势
    [mmDrawerVC setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    mmDrawerVC.tabBarItem.title = @"精华";
    mmDrawerVC.tabBarItem.image = [UIImage imageNamed:@"tabBar_essence_icon"];
    mmDrawerVC.tabBarItem.selectedImage = [UIImage imageNamed:@"tabBar_essence_click_icon"];
    [self addChildViewController:mmDrawerVC];
    
    
    
    [self createClass:[[CCYNewViewController alloc] init] title:@"新帖" image:@"tabBar_new_icon" selectedImage:@"tabBar_new_click_icon"];
    
    [self createClass:[[CCYFriendTrendsViewController alloc] init] title:@"关注" image:@"tabBar_friendTrends_icon" selectedImage:@"tabBar_friendTrends_click_icon"];
    
    [self createClass:[[CCYMeViewController alloc] init] title:@"我" image:@"tabBar_me_icon" selectedImage:@"tabBar_me_click_icon"];
    
    
    
    
    
    
    [self setValue:[[CCYTabBar alloc] init] forKey:@"tabBar"];
    
}

- (void)createClass:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    CCYNavigationController *nav = [[CCYNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
